#include <string.h>

// Declare global variables
int MAX_COMMAND_SIZE = 10;
int MAX_NUM_PARAMS = 5;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  
    if (Serial.available()) {
    int positionCnt = 0;
    // Declare arrays to store parsed params
    char parm1[MAX_COMMAND_SIZE];
    char parm2[MAX_COMMAND_SIZE];

    
     // Declare buffer to receive serial data
    char buffer[MAX_COMMAND_SIZE * MAX_NUM_PARAMS + MAX_NUM_PARAMS]; 
    // Determines number of characters read into buffer
    int tempLen = Serial.readBytesUntil('\n',
      buffer, MAX_COMMAND_SIZE * MAX_NUM_PARAMS + MAX_NUM_PARAMS); 
    
    char command[tempLen + 1]; // Initialize array to store command
    
    // Transfer command from buffer into command array
    int i;
    for( i = 0; i < tempLen; i++) {  
      command[i] = buffer[i];
    }
    command[i + 1] = '\0';
    
    // Parse first word in command
    for(i = 0; i < tempLen && command[positionCnt] != ' ' && command[positionCnt] != '\0'; i++) {
      parm1[i] = command[positionCnt];
      positionCnt++;
    }
    parm1[i] = '\0';
    positionCnt++;

    if(strcmp(parm1,"") == 0)
    {
      
    } else if(strcmp(parm1,"s") == 0) 
    {

    } else if(strcmp(parm1,"") == 0){

    }
    else if(strcmp(parm1,"r") == 0) 
    {

    }
  }
  
}



